<form action="./m.php?frm=action&mdl=index" name="iForm" id="iForm" method="post" enctype="multipart/form-data" target="eBody">
	<input type="hidden" name="id" id="id" value="{$info.id}" />
	<input type="hidden" name="related_news" id="related_news" value="{$info.related_news}" />

	<table border="0" align="center" cellpadding="0" cellspacing="1" class="data_form">
		<caption>
		{$_page.caption}
		</caption>
		<tbody>
			<tr>
				<th style="width:160px;">{$l.name}：</th>
				<td><input type="text" name="name" id="name" value="{$info.name}" class="input" style="width:480px;" /></td>
			</tr>
			<tr>
				<th>{$l.mark}：</th>
				<td><input type="text" name="mark" id="mark" value="{$info.mark}" class="input" style="width:240px;" /></td>
			</tr>
			<tr>
				<th>URL：</th>
				<td><input type="text" name="url" id="url" value="{$info.url}" class="input" style="width:480px;" /></td>
			</tr>
			<tr>
				<th>LOGO：</th>
				<td><b class="file">＋选择图片<input type="file" name="logo" class="input" /></b>
					<input type="hidden" name="logoold" value="{$info.logo}" />
					{if $info.logo != ''}
					<div class="img">
						<a href="{$_s.up_dir}{$info.logo}" title="{$info.name}" class="open_frame"> <img src="{$_s.up_dir}thumb/{$info.logo}" onload="drawImage(this, 200, 120);" width="10" height="10" /> </a>
					</div>
					<input type="checkbox" name="dellogo" value="1" class="chbox" />删除
					{/if}			
				</td>
			</tr>
			<tr>
				<th>{$l.rank}：</th>
				<td><input type="text" name="rank" id="rank" value="{$info.rank}" class="input" style="width:64px;" /></td>
			</tr>
			<tr>
				<th>{$l.content}：</th>
				<td class="compact">
					<!-- <script type="text/plain" id="content"style="width:100%;">
					{$info.content}
					</script> -->
					<textarea name="content" id="content">{$info.content}</textarea></td>
			</tr>
			<tr>
				<th></th>
				<td></td>
			</tr>
			<tr>
				<th>关联新闻：</th>
				<td><ul id="related_news_list" class="adaptation">
					<!-- 关联新闻列表 START -->
					{foreach from=$info.related_news_list item=news}
					<li>
						<i id="{$news.id}"><img src="{$_s.img_dir}gif/file_del.gif"></i>
						<a class="open_frame" href="./m.php?frm=news&amp;mdl=news&amp;do=edit&amp;id={$news.id}">{$news.title}</a>
					</li>
					{/foreach}
					<!-- 关联新闻列表 END -->
				</ul><div class="clear"></div>
				<input type="button" value="添加关联新闻" class="button" func="open_frame" href="./m.php?frm=news&mdl=news&do=list&catid=2&_filter=yes" title="新闻列表" /></td>
			</tr>

		</tbody>
		
		<tfoot id="cmd">
			<tr>
				<th>&nbsp;</th>
				<td><button name="formAction" value="{$_act.frm}.{$_act.mdl}_{$_act.do}" class="button">{$l.submit}</button>
					<input type="reset" name="btnReset" value="{$l.reset}" class="button" /></td>
			</tr>
		</tfoot>
	</table>
</form>



<script type="text/javascript" charset="utf-8" src="{$_s.lib_dir}ueditor/editor_config.js"></script>
<script type="text/javascript" charset="utf-8" src="{$_s.lib_dir}ueditor/editor_all_min.js"></script>
<script type="text/javascript" language="JavaScript" charset="utf-8">
<!--
	{literal}
	jQuery(function($){
		add_nav_btn({
			'dir'		: '#related_news_list'
			,'title'	: '滚动到相关新闻区'
			,'text'		: '新闻'
			,'ttl'		: 100
		});
		/*******************************************************************************
		 * 表单验证
		 *******************************************************************************/
		var objVf = $('form#iForm').Validform({
			showAllError	: true			// 显示所有错误提示信息
			,label			: 'th'			// 在没有绑定nullmsg时查找要显示的提示文字，默认查找".Validform_label"下的文字
			,tiptype		: vf_fadein		// 自定义
			// ,tiptype		: 3 			// 右侧
			,beforeSubmit	: function(fm){	// 隐藏或不可见元素在这里判断
				var errmsg = [];
				var content	= $.trim(fm.find('[name="content"]').val());
				if(content == '')errmsg.push('请输入品牌内容');
				if(errmsg.length > 0){
					showmsg_warning(errmsg.join('<br />'));
					return false;
				}
			}
		});
		
		objVf.addRule([
			{	ele : 'input[name="name"]',		datatype : 's2-50'		}
			,{	ele : 'input[name="mark"]',		datatype : 'c2-20'		}
			,{	ele : 'input[name="url"]',		datatype : 'url' 	}
			,{	ele : 'input[name="rank"]',		datatype : 'n1-11' 	}
		]);

	});
	//实例化百度编辑器
	var ueconfig = $.extend({}, __ueconfig, {
	});
	ueditor = UE.getEditor('content', ueconfig);

	{/literal}


	/*******************************************************************************
	 * 关联新闻对象
	 *******************************************************************************/
	var related_news_json = $.trim('{$info.related_news_json}');
	
	{literal}
	var related_news_obj = {};
	if(related_news_json != ''){
		try{
			var json = $.json.decode(related_news_json);
			if(typeof json == 'object'){
				related_news_obj = json;
			}
		}catch(e){}
	}
	//console.dir(related_news_obj);

	jQuery(function($){
		// 删除关联新闻
		$('#related_news_list > li > i').live('click', function(){
			var newsid = $(this).attr('id');
			related_news_obj[newsid] = undefined;
			delete related_news_obj[newsid];
			$(this).parent().remove();
			_update_related_news_obj();
		});
	});

	/*******************************************************************************
	 * 关联新闻，返回数据处理
	 *******************************************************************************/
	function _receive_news(news_arr){
		for(i = 0; i < news_arr.length; i ++){
			var tf = typeof(related_news_obj[news_arr[i].id]);
			if(tf == 'undefined'){
				related_news_obj[news_arr[i].id] = news_arr[i];
				_append_news(news_arr[i]);
			}
		}
		_update_related_news_obj();
	}
	function _update_related_news_obj(){
		var ids = [];
		for(var newsid in related_news_obj){
			ids.push(newsid);
		}
		if(ids.length > 0){
			ids = ','+(ids.join(','))+',';
		}else{
			ids = '';
		}
		$('#iForm').find('input[type="hidden"][name="related_news"]').val(ids);
	}
	function _append_news(news){
		$('#related_news_list').append('<li><i id="'+news.id+'"><img src="'+_s.img_dir+'gif/file_del.gif" /></i><a href="./m.php?frm=news&mdl=news&do=edit&id='+news.id+'" class="open_frame">'+news.title+'</a></li>');
	}
	{/literal}
-->
</script>
